package com.gton.service;

import com.gton.io.RPCUserManagerRequest;
import com.gton.io.Resp;
import com.gton.router.RemoteThirdSysRouterService;
import com.gton.util.NanoIdUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @description: RPC---Dubbbo---UserManager
 * @author: GuoTong
 * @createTime: 2022-10-22 15:27
 * @since JDK 1.8 OR 11
 **/
@Service
@Slf4j
public class DubboRPCUserManager {


    /**
     * Description:  dubbo RPC  消息请求方  @DubboReference
     *
     * @author: GuoTong
     * @date: 2022-10-22 15:29:15
     */
    @DubboReference
    private RemoteThirdSysRouterService remoteThirdSysRouterService;

    public Resp requestUserManager() {
        RPCUserManagerRequest rpcUserManagerRequest = new RPCUserManagerRequest();
        rpcUserManagerRequest.setAge(18);
        rpcUserManagerRequest.setEmail("1054769749@qq.com");
        rpcUserManagerRequest.setQqNumber("1054769749");
        rpcUserManagerRequest.setTital("RPC调用UserManger服务");
        rpcUserManagerRequest.setTraceId(NanoIdUtils.randomNanoId());
        rpcUserManagerRequest.setBeginTime(LocalDateTime.now());
        rpcUserManagerRequest.setToServer("usermanager");
        rpcUserManagerRequest.setFormServer("thirdsysrouter");
        rpcUserManagerRequest.setVersion("1.0.0");
        rpcUserManagerRequest.setUserSessionKey("Guotong");
        return remoteThirdSysRouterService.requestInfo(rpcUserManagerRequest);
    }

}
